import Http from 'http2';

const client = Http.connect('http://localhost:8888');
client.on('error', (e) => console.error(e));

const req = client.request({
  ':path': '/',
});

req.on('response', (h, f) => {
  for (const name in h) {
    console.log(`${name}: ${h[name]}`);
  }
})

req.setEncoding('utf8');
let data = '';
req.on('data', (chunk) => data += chunk);
req.on('end', () => {
  console.log(`\n${data}`);
  client.close();
});
req.end();